package com.kh.pajx.sop.service.bal.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kh.pajx.sop.base.BaseServiceImpl;
import com.kh.pajx.sop.dao.bal.IBalCustMgrDriveDao;
import com.kh.pajx.sop.domain.bal.BalCustMgrDrive;
import com.kh.pajx.sop.service.bal.IBalCustMgrDriveService;
import com.kh.pajx.sop.util.page.QueryHelper;

@Service
@Transactional
public class BalCustMgrDriveServiceImpl extends BaseServiceImpl<BalCustMgrDrive> implements IBalCustMgrDriveService {
	
	@Resource
	private IBalCustMgrDriveDao balCustMgrDao;

	@Override
	public List<BalCustMgrDrive> findNewList() throws Exception {
		return balCustMgrDao.findListByState(0);
	}

	@Override
	public List<BalCustMgrDrive> findAppList() throws Exception {
		return balCustMgrDao.findListByState(1);
	}

	@Override
	public List<BalCustMgrDrive> findCheckList() throws Exception {
		return balCustMgrDao.findListByState(2);
	}

	@Override
	public List<BalCustMgrDrive> findPayList() throws Exception {
		return balCustMgrDao.findListByState(3);
	}
	
	@Override
	public void showNewList(String deptCode, int pageNum, int numPerPage) {
		new QueryHelper(BalCustMgrDrive.class, "bal")
		.addCondition("bal.saleDeptId=?", deptCode)
		.addCondition("bal.billState=?", 0)
		.addOrderProperty("bal.ywEndDate", false)
		.addOrderProperty("bal.saleDeptId", true)
		.addOrderProperty("bal.sclName", true)
		.preparePageBean(balCustMgrDao, pageNum, numPerPage);
	}
	
	@Override
	public List<BalCustMgrDrive> findList(String billCode, int billState) throws Exception {
		return balCustMgrDao.findList(billCode, billState);
	}
	
	@Override
	public void findCustMgrHisBySclId(String sclId, int pageNum, int numPerPage) throws Exception {
		new QueryHelper(BalCustMgrDrive.class, "bal")
		.addCondition("bal.sclId=?", sclId)
		.addOrderProperty("bal.ywEndDate", false)
		.addOrderProperty("bal.saleDeptId", true)
		.addOrderProperty("bal.sclName", true)
		.preparePageBean(balCustMgrDao, pageNum, numPerPage);
		
	}

	@Override
	public BalCustMgrDrive getById(String uuid) {
		return balCustMgrDao.getById(uuid);
	}
}
